package com.lib.model.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.scheduling.annotation.Async;

import com.lib.model.dto.BookReviewDto;
import com.lib.model.dto.BookSearchDto;

public class BookSearchDao extends SqlMapClientDaoSupport implements
		IBookSearchDao {

	@Override
	public ArrayList<BookSearchDto> getAllBookList(int startPage,
			int startBlock, String searchType, String searchValue) {
		ArrayList<BookSearchDto> list = null;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startpage", startPage);
		map.put("endpage", startBlock);
		map.put("searchType", searchType);
		map.put("searchValue", searchValue);

		list = (ArrayList<BookSearchDto>) getSqlMapClientTemplate()
				.queryForList("BookSearch.getAllBook", map);

		return list;
	}

	@Override
	public int getBookSearchCount(String searchType, String searchValue) {

		int count = 0;

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("searchType", searchType);
		map.put("searchValue", searchValue);

		count = (Integer) getSqlMapClientTemplate().queryForObject(
				"BookSearch.getBookSearchCount", map);
 
		return count;
	}

}
